/**
 * Created by losor on 2017/3/15.
 */
public class _66_PlusOne {

    public int[] plusOne(int[] digits) {
        for (int i = digits.length-1; i >=0; i--) {
            if (digits[i] == 9){
                digits[i] = 0;
            }
            else{
                digits[i] += 1;
                return digits;
            }
        }
        int[] out = new int[digits.length+1];
        out[0] = 1;
        return out;

    }

}
